package com.lingnan.tijian.controller;

import com.lingnan.tijian.domain.Hospital;
import com.lingnan.tijian.domain.Users;
import com.lingnan.tijian.dto.ApiResponse;
import com.lingnan.tijian.service.ifac.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class HospitalController {
    @Autowired
    HospitalService hospitalService;

    /**
     * 查询医院信息列表的方法
     */
    @RequestMapping("/listHospital")
    public ApiResponse listHospital(@RequestBody Hospital hospital,HttpServletRequest request){
        Users user=(Users)request.getAttribute("user");
        System.out.println("医院controller方法输出结果："+user.getUserId());
        System.out.println("listHospital:"+hospital.getState());


        return hospitalService.listHospital(hospital.getState());
    }

    @RequestMapping("/getHospitalById")
    public ApiResponse getHospitalById(@RequestBody Hospital hospital){
        return hospitalService.getHospitalById(hospital.getHpId());
    }


}
